FILE_NAME = "cmd.txt"
print(f"please put commands line by line in \"{FILE_NAME}\"\n")
import robot_command_control as rmc
import os
# cmd = ["mv 100 01", "r 9", "r 6 6", "mt 45", "mv hello ha"]


def cmd_filter(cmd):
    out = []
    for k, i in enumerate(cmd):
       legal, err = rmc.command_dealer(i, False)
       if not legal:
           print(f"Line {k} was illegal: \t {i}")
       else:
            out.append(i)
    print(f"{k+1} lines of command will be executed in a loop.")
    return out

def main():
    if not os.path.exists(FILE_NAME):
        with open(FILE_NAME, "w") as f:
            ...
    with open(FILE_NAME, "r") as f:
        cmd = f.readlines()
    cmd = cmd_filter(cmd)
    while True:
        for i in cmd:
            print(i)
            rmc.command_dealer(i, True)           


if __name__ == "__main__":
    main()